package com.ruoyi.business.controller;

import com.ruoyi.business.domain.TenantFunctionComposite;
import com.ruoyi.business.domain.TenantFunctionMain;
import com.ruoyi.business.service.ITenantFunctionMainService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 租户组件功能点主表Controller
 *
 * @author ruoyi
 * @date 2025-04-19
 */
@RestController
@RequestMapping("/tenantFunctionMain")
public class TenantFunctionMainController extends BaseController
{
    @Autowired
    private ITenantFunctionMainService tenantFunctionMainService;

    /**
     * 查询租户组件功能点主表列表
     */
    @RequiresPermissions("business:tenantFunctionMain:list")
    @GetMapping("/list")
    public TableDataInfo list(TenantFunctionMain tenantFunctionMain)
    {
        startPage();
        List<TenantFunctionMain> list = tenantFunctionMainService.selectTenantFunctionMainList(tenantFunctionMain);
        return getDataTable(list);
    }

    /**
     * 导出租户组件功能点主表列表
     */
    @RequiresPermissions("business:tenantFunctionMain:export")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TenantFunctionMain tenantFunctionMain)
    {
        List<TenantFunctionMain> list = tenantFunctionMainService.selectTenantFunctionMainList(tenantFunctionMain);
        ExcelUtil<TenantFunctionMain> util = new ExcelUtil<TenantFunctionMain>(TenantFunctionMain.class);
        util.exportExcel(response, list, "租户组件功能点主表数据");
    }

    /**
     * 获取租户组件功能点主表详细信息
     */
    @RequiresPermissions("business:tenantFunctionMain:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tenantFunctionMainService.selectTenantFunctionMainById(id));
    }

    /**
     * 新增租户组件功能点主表
     */
    @RequiresPermissions("business:tenantFunctionMain:add")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TenantFunctionMain tenantFunctionMain)
    {
        return toAjax(tenantFunctionMainService.insertTenantFunctionMain(tenantFunctionMain));
    }

    /**
     * 修改租户组件功能点主表
     */
    @RequiresPermissions("business:tenantFunctionMain:edit")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TenantFunctionMain tenantFunctionMain)
    {
        return toAjax(tenantFunctionMainService.updateTenantFunctionMain(tenantFunctionMain));
    }

    /**
     * 删除租户组件功能点主表
     */
    @RequiresPermissions("business:tenantFunctionMain:remove")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tenantFunctionMainService.deleteTenantFunctionMainByIds(ids));
    }
    /**
     * 提交新增租户组件功能点
     */
    @RequiresPermissions("business:tenantFunctionMain:add")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.INSERT)
    @PostMapping("/commitadd")
    public AjaxResult commitAdd(@RequestBody TenantFunctionComposite tenantFunctionComposite)
    {
        return AjaxResult.success(tenantFunctionMainService.commitInsertTenantFunctionMain(tenantFunctionComposite));
    }
    /**
     * 提交更新租户组件功能点
     */
    @RequiresPermissions("business:tenantFunctionMain:update")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.UPDATE)
    @PostMapping("/commitupdate")
    public AjaxResult commitUpdate(@RequestBody TenantFunctionComposite tenantFunctionComposite)
    {
        return toAjax(tenantFunctionMainService.commitUpdateTenantFunctionMain(tenantFunctionComposite));
    }
    /**
     * 保存新增租户组件功能点
     */
    @RequiresPermissions("business:tenantFunctionMain:add")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.INSERT)
    @PostMapping("/insertTenantFunctionComposite")
    public AjaxResult insertTenantFunctionComposite(@RequestBody TenantFunctionComposite tenantFunctionComposite)
    {
        return AjaxResult.success(tenantFunctionMainService.insertTenantFunctionComposite(tenantFunctionComposite));
    }
    /**
     * 保存更新租户组件功能点
     */
    @RequiresPermissions("business:tenantFunctionMain:update")
    @Log(title = "租户组件功能点主表", businessType = BusinessType.UPDATE)
    @PostMapping("/updateTenantFunctionComposite")
    public AjaxResult updateTenantFunctionComposite(@RequestBody TenantFunctionComposite tenantFunctionComposite)
    {
        return toAjax(tenantFunctionMainService.updateTenantFunctionComposite(tenantFunctionComposite));
    }
}
